package cn.bdqn.service.impl;


import cn.bdqn.domain.Doctor;
import cn.bdqn.domain.DoctorDiagnose;
import cn.bdqn.domain.Menber;
import cn.bdqn.domain.Room;
import cn.bdqn.mapper.DoctorDiagnoseMapper;
import cn.bdqn.mapper.DoctorMapper;
import cn.bdqn.mapper.MenberMapper;
import cn.bdqn.mapper.RoomMapper;
import cn.bdqn.service.MenberService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author 病人信息的业务实现
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class MenberServiceImpl implements MenberService {

    @Resource
    private MenberMapper menberMapper;

    /**
     * 根据病人信息id查询病人信息
     * @param id
     * @return
     */
    @Override
    public Menber queryById(Integer id) {
        return menberMapper.selectByPrimaryKey(id);
    }

    /**
     * 添加病人信息
     * @param menber
     * @return
     */
    @Override
    @Transactional( rollbackFor =Exception.class ,propagation = Propagation.REQUIRES_NEW)
    public int addMenber(Menber menber) {
        return menberMapper.insert(menber);
    }

    /**
     * 判断数据库是否有相同的数据
     * @param MenberIdcard
     * @return
     */
    @Override
    public int queryVerifyByMenberIdcard(String MenberIdcard) {
        return menberMapper.selectVerifyByMenberIdcard(MenberIdcard);
    }

    /**
     * 根据id修改预存款
     * @param id
     * @param menberPrestore
     * @return
     */
    @Override
    public int updateMenberPrestoreByMenberId(int id, double menberPrestore) {
        return menberMapper.updateMenberPrestoreByMenberId(id,menberPrestore);
    }



}
